package cc.orange.adapter;

import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import cc.orange.entity.PersonMsgEntity;

import cc.orange.R;


/**
 */

public class AppraiseAdapter extends BaseQuickAdapter<PersonMsgEntity.Data.PingJia, BaseViewHolder> {

    private ItemClickListener itemClickListener;
    public AppraiseAdapter(@Nullable List<PersonMsgEntity.Data.PingJia> data) {
        super(R.layout.item_appraise, data);
    }

    public void setItemClickListener(ItemClickListener itemClickListener){
        this.itemClickListener = itemClickListener;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, PersonMsgEntity.Data.PingJia item) {

        RelativeLayout item_appra_rel1 = helper.getView(R.id.item_appra_rel1);
        TextView item_appra_text1 = helper.getView(R.id.item_appra_text1);
        item_appra_text1.setText(item.getEvaluate());
        if(item.getStatus() == 1){
            item_appra_rel1.setBackgroundResource(R.drawable.shape_appraise_back);
            item_appra_text1.setTextColor(mContext.getResources().getColor(R.color.color_838383));
        }else{
            item_appra_rel1.setBackgroundResource(R.drawable.shape_appraise);
            item_appra_text1.setTextColor(mContext.getResources().getColor(R.color.color_ff3062));
        }

        item_appra_rel1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(null != itemClickListener){
                    itemClickListener.itemClickListenr(helper.getLayoutPosition());
                }
            }
        });
    }


    public interface ItemClickListener{
        void itemClickListenr(int position);
    }
}
